import com.alibaba.fastjson.JSON;
import com.book.entity.Book;
import com.book.entity.Borrow;
import com.book.entity.Student;
import com.book.service.BookService;
import com.book.service.StudentService;
import com.book.service.impl.BookServiceImpl;
import com.book.service.impl.StudentServiceImpl;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.ibatis.annotations.Select;
import org.junit.jupiter.api.Test;

import java.util.*;

/*
 **@Author:youpeng
 **Created on 2022/4/25
 */
public class Main {

    BookService bookService=new BookServiceImpl();
    StudentService studentService=new StudentServiceImpl();

    @Test
    public void test1(){
        System.out.println(bookService.getBorrowList().size());
        System.out.println(bookService.getBookList().size());
        System.out.println(studentService.getStudentList().size());
    }

    @Test
    public void test2(){
        /*Map<Book, Boolean> bookList = bookService.getBookList();
        double numPrice= bookList.keySet().stream().mapToDouble(Book::getPrice).sum();
        System.out.println(numPrice);*/
        Map map=new HashMap();
    }

    @Test
    public void test3(){
        Page<Student> page = PageHelper.startPage(1, 3);
        List<Student> list = studentService.getStudentListLike("小");
        list.forEach(System.out::println);
        //System.out.println(page);
        PageInfo<Student> pageInfo = new PageInfo<>(list, 5);
        System.out.println(pageInfo);
        System.out.println(pageInfo.getPages());
        //System.out.println(pageInfo.getNavigatepageNums());
        /*String s = JSON.toJSONString(pageInfo.getNavigatepageNums());
        List<String> list1=Arrays.asList(s);
        System.out.println(list.get(1));
        list1.forEach(System.out::println);*/
    }

    @Test
    public void test4(){
        /*Page<Book> page = PageHelper.startPage(1, 3);
        Map<Book, Boolean> bookMap = bookService.getBookListLike("");
        bookMap.keySet().forEach(System.out::println);
        bookMap.values().forEach(System.out::println);
        System.out.println(page);
        List<Book> books = new ArrayList<>(bookMap.keySet());
        PageInfo<Book> pageInfo = new PageInfo<>(books, 5);
        System.out.println(pageInfo);*/
        Page<Borrow> page = PageHelper.startPage(1, 1);
        List<Borrow> borrowListLike = bookService.getBorrowListLike("");
        PageInfo<Borrow> pageInfo = new PageInfo<>(borrowListLike, 5);
        borrowListLike.forEach(System.out::println);
        System.out.println(page);
        System.out.println(pageInfo);
    }
}
